package com.example.mywechatprogram.mapper;

import com.example.mywechatprogram.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
public interface UserMapper {
    @Insert("insert into users (users_nickname, users_password) values (#{nickname},#{password})")
    public int addUser(User user);
    @Select("select users_UUID from users where users_nickname=#{nickname}")
    public String getUUID(String nickname);

    @Select("select users_UUID from users where users_nickname=#{user.nickname} and users_password=#{user.password}")
    public String login(@Param("user") User user);

    @Update("update users set users_password=#{newPassword} where users_nickname=#{nickname} and users_password=#{password}")
    public int update(@Param("nickname") String nickname,@Param("password")String password,@Param("newPassword") String newPassword);

    @Delete("delete from users where users_nickname=#{nickname} and users_password=#{password}")
    public int del(@Param("nickname") String nickname,@Param("password")String password);

    @Insert("insert users_sculpture (UUID, sculpture) values (#{UUID},0)")
    public int insertSculpture(@Param("UUID") String UUID);
}
